﻿#region
/* ===============================================
 * 作者：guopeng           时间：2012/2/16 19:47:45
 * 
 * 
 * 类描述：
 * 
 * 
 * =============================================== */
#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;
using ueEngine.Biz.Inf.Entities.DBSupport;
using ueEngine.Framework.Exception;

namespace ueEngine.Biz.Inf.Entities
{
    /// <summary>
    /// 微评论
    /// </summary>
    [Table("ShortDiscuss")]
    public class ShortDiscuss : BaseEntity<ShortDiscuss>
    {
        public ShortDiscuss() { }
        public override ShortDiscuss Get(System.Linq.Expressions.Expression<Func<ShortDiscuss, bool>> where)
        {
            using (Context ctx = new Context())
            {
                var item = ctx.ShortDiscuss.FirstOrDefault(where);
                if (item != null)
                {
                    this.Author = item.Author;
                    this.Content = item.Content;
                    this.Id = item.Id;
                    this.ReferenceCode = item.ReferenceCode;
                    this.ReferenceId = item.ReferenceId;
                    this.WriteDate = item.WriteDate;
                    this.Down = item.Down;
                    this.Up = item.Up;
                    this.Appraise = item.Appraise;
                    this.IsDelete = item.IsDelete;
                    return this;
                }
                return null;
            }
        }
        #region Fileds
        [Key]
        [Column("Id", TypeName = "int")]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }
        
        /// <summary>
        /// 关联的信息资源Id
        /// </summary>
        [Column("ReferenceId", TypeName = "int")]
        public int ReferenceId { get; set; }
        
        /// <summary>
        /// 关联的模块代码
        /// </summary>
        [Column("ReferenceCode", TypeName = "int")]
        public int ReferenceCode { get; set; }

        /// <summary>
        /// 编写时间
        /// </summary>
        [Column("WriteDate",TypeName="datetime")]
        public DateTime WriteDate { get; set; }

        /// <summary>
        /// 作者
        /// </summary>
        [Column("Author",TypeName="nvarchar")]
        [StringLength(200)]
        public string Author { get; set; }

        /// <summary>
        /// 文本
        /// </summary>
        [Column("Content", TypeName = "nvarchar")]
        [StringLength(1000)]
        public string Content { get; set; }

        /// <summary>
        /// 赞同次数
        /// </summary>
        [Column(TypeName="int")]
        public int Up { get; set; }

        /// <summary>
        /// 反对次数
        /// </summary>
        [Column(TypeName="int")]
        public int Down { get; set; }

        /// <summary>
        /// 评价
        /// </summary>
        [Column(TypeName="int")]
        public int Appraise { get; set; }

        [Column(TypeName="bit")]
        public bool IsDelete { get; set; }
        #endregion
    }
}
